There was a time not long ago when Nissan Motor made all of its cars at home and shipped them fully-built to countries around the world.

Today Nissan assembles cars in Malaysia, Mexico, Portugal and other countries. If plans on the drawing boards come true, it will soon be building finished cars in Britain, pickup trucks in Tennessee, and hybrid Nissans-Alfa Romeos in Italy.

The turnabout for Nissan is the tip of a big surge in foreign investments for Japanese corporations which in the past few years have discovered the merits of sending money, not just products, abroad.

They have built petrochemical plants in the Middle East and television sets in the United States and are looking forward to the time when they make plastics in Brazil, ethyl alcohol in Sumatra, Indonesia, pharmaceutical drugs in the United States, and bauxite processing plants in Indonesia and Australia.

An important factor in sending Japense capital abroad -- perhaps the major one -- has been pressure from foreign countries, including the United States where one in every four cars sold is made in Japan. A bill has been introduced in the U.S. Senate to restrict the import of Japanese cars.

Some industrialized countries already have, explicitly or not, restricted their markets to Japanese imports so that Japan must build there to sell there. For example, Italy will allow only 2,200 Japanese cars a year to be imported. France appears to have set an informal limit of 3 percent of its car market for Japan, and Britain has warned Japan not to take more than 10 or 11 percent of its car sales.

Nissan will get inside the European Community's trade walls by building cars there. Eventually it will build 200,000 small cars a year in Britain and will produce medium and small-sized cars in a joint venture with Italy's Alfa-Romeo.

Nissan's plan to build a pickup truck factory in Tennessee also may have been a result of an increase in U.S. import duties.

The new era has taken Nissan far from the period when it built cars here and watched them float away from Japanese docks to the far corners of the world. Pressures from developing countries also forced the company to build assembly plants abroad and ship knocked-down versions that are put together overseas by local labor. This year, 200,000 unassembled cars will be shipped.

"For a long time, we assumed we could not make money overseas, a Nissan official commented recently. "That is not the easiest way. Physically, its easier to make cars here and ship them abroad. But in the long run, that would cause a lot of problems."

"The new era," as some confident officials call the surge in overseas investment, has brought Japan into the second tier of industrial countries in terms of foreign investment. It lags far behind the United States but is in close competition with West Germany and Britain. Japan's overseas investments rose from a modest $4 billion in 1970 to a cumulative $27 billion in 1978. The new wave, says the Japan Economic Research Center, will carry it to about $74 billion in another four years.

In 1979, the investments nearly hit $5 billion, about double the amount of two years earlier, and one international analysts' study forecasts average investments of $6 billion to $7 billion in the coming years.

The direction of those investments has also changed significantly during the late 1970s. Once it was loaded toward the poor countries where labor was cheap for making toys and textiles. Now a larger share is heading into North America and Western Europe where the Japanese now figure their technology and managerial style make them competitive.

"Most of their manufacturing investment used to be in Asia," observed James Rudy, director of Investment Business Information, who conducted the study. "But now its going to protect their market share in things like autos and electronics in the U.S. and Europe."

Several other economic threads have come together at once to spark the new surge, economists point out. The Japanese yen appreciated considerably during the past four years, permitting the corporation based here to buy more for less abroad. Japan developed a labor shortage and labor costs rose at home.

The costs of some raw materials, like oil, went straight up in Japan, reducing the profitability of making some products at home. Sumitomo Chemical chairman Norishige Hasegawa says oil is so expensive now that when his company builds a new petrochemical plant it will probably be in the United States or Canada, where oil is cheaper.

Toyota, Nissan's competitor here, has been far more reluctant to invest in production abroad, although it too assembles many vehicles in other countries. "It is not Toyota's style to go in with a lot of money and start producing things," said Nobuji Araki, executive vice president of Toyota Motor Sales. Building a factory in France, for example, he said, would be simply recognizing the restrictions on imports imposed there.

Toyota has examined intensely the prospects of building a plant in the United States. Araki said in an interview that interim reports are "basically negative" from the standpoint of profitability. He said there will be "no dramatic increases" anywhere for Toyota investments in the coming decade.

But Toyota appears to be an exception among big Japanese companies.

"Sumitomo Chemicals has lost competitiveness to some foreign countries and so we must invest more abroad," said the company's chairman, Hasegawa.

The demands of developing countries are partly responsible. Exporters of bauxite and other raw materials want the processing done on their shores to provide local employment. Sumitomo is expecting processing to start in Indonesia, Australia, Brazil and Venezuela.

In another switch, Japanese corporations also have become bolder in agreeing to technological tie-ups with foreign companies they often compete against. In the past two years, a number of major foreign firms have come to Japan seeking co-production or technological aid tie-ups. Such Japanese giants as Nippon Steel and Kawasaki Steel are linked up with two American steel manufacturers, Armco and Republic, and reports of new ventures sought by technology-hungry American firms are reported every day. Once it was the other way around, with Japanese companies seeking foreign investment and technological aid.